ADCBuf_init();
ADCBuf_Params adcBufParams;
ADCBuf_Params_init(&adcBufParams);

adcBufParams.source = ADCBUF_SOURCE_DFE;
adcBufParams.continousMode = continousMode;  //连续模式
adcBufParams.chirpThresholdPing = chirpThresholdVal;
adcBufParams.chirpThresholdPong = chirpThresholdVal;
adcBufParams.custom = &adcBufParams;

adcBufParams.socHandle = MMWave_Global_Params.handle.socHandle;

MMWave_Global_Params.handle.adcbuf_handle = ADCBuf_open(0,&adcBufParams);
if (MMWave_Global_Params.handle.adcbuf_handle == NULL )
{
    System_printf ("Error: ADCBuf Initialization failed\n");
}
 ADCBuf_RxChanConf   rxChanConf;
    memset((void *)&rxChanConf, 0, sizeof(ADCBuf_RxChanConf));
    rxChanConf.channel = 0;
    rxChanConf.offset = 0;

    for (channel = 0; channel < SYS_COMMON_NUM_RX_CHANNEL; channel++)
    {
        rxChanConf.channel = channel;
        retVal = ADCBuf_control(MMWave_Global_Params.handle.adcbuf_handle, ADCBufMMWave_CMD_CHANNEL_ENABLE, (void *)&rxChanConf);
        if (retVal < 0)
        {
            System_printf ("Error: ADCBuf Channel Enable failed\n");
        }
        rxChanConf.offset  += 128 * 4 * chirpThresholdVal;  //chanDataSize * chirpThresholdVal;
        // 128*4的原因是16位复数采样 就是16*2 换算过来就是4byte 然后ADC只采96个 但要按2^N也就是128对齐 所以每个RX通道第96个byte后面的都是0
    }

retVal = ADCBuf_control(MMWave_Global_Params.handle.adcbuf_handle, ADCBufMMWave_CMD_SET_PING_CHIRP_THRESHHOLD,(void *)&chirpThresholdVal);
if(retVal < 0)
{
    System_printf ("Error: ADCBuf Ping Chirp THRESHHOLD failed\n");
}

retVal = ADCBuf_control(MMWave_Global_Params.handle.adcbuf_handle, ADCBufMMWave_CMD_SET_PONG_CHIRP_THRESHHOLD,(void *)&chirpThresholdVal);
if(retVal < 0)
{
    System_printf ("Error: ADCBuf Pong Chirp THRESHHOLD failed\n");
}

retVal = ADCBuf_control(MMWave_Global_Params.handle.adcbuf_handle, ADCBufMMWave_CMD_SET_CONTINUOUS_MODE,(void *)&continousMode);
if(retVal < 0)
{
    System_printf ("Error: ADCBuf Set Continuous Mode failed\n");
}

retVal = ADCBuf_control(MMWave_Global_Params.handle.adcbuf_handle, ADCBufMMWave_CMD_START_CONTINUOUS_MODE ,(void *)&continousMode);
if(retVal < 0)
{
    System_printf ("Error: ADCBuf Start Continuous Mode failed\n");
}

//get data
ADCBuf_Conversion blockingConversion;
blockingConversion.arg = NULL;
blockingConversion.adcChannel = Board_ADCCHANNEL_A1;
blockingConversion.sampleBuffer = sampleBufferOnePtr;
blockingConversion.sampleBufferTwo = NULL;
blockingConversion.samplesRequestedCount = ADCBUFFERSIZE;
if (!ADCBuf_convert(adcBuf, &continuousConversion, 1)) {
    // handle error
}

//get data2
/*! L3 RAM buffer for object detection DPC */
uint8_t L3_RAM_Buf[SOC_L3RAM_SIZE]={0};
#pragma DATA_SECTION(L3_RAM_Buf, ".l3ram");
static uint8_t chirp_updata_flag=0;
void MMWave_chirpIntCallback(uintptr_t arg)
{
    int32_t         errCode;
    uint8_t channel=0;
    uint32_t add=0;

    for(channel=0;channel<4;channel++)
    {
        add = ADCBuf_getChanBufAddr(MMWave_Global_Params.handle.adcbuf_handle,channel,&errCode);
        memset(&L3_RAM_Buf[chirp_updata_flag*2048+channel*512],0,512);
        memcpy(&L3_RAM_Buf[chirp_updata_flag*2048+channel*512],(void *)add,512);
    }
    chirp_updata_flag++;
    if(chirp_updata_flag==96)
    {
        chirp_updata_flag=0;
    }
}
